package com.tudouji.project.produce.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.produce.domain.Whinapplyitem;
import com.tudouji.project.produce.service.IWhinapplyitemService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 入库申请单明细Controller
 * 
 * @author tudouji
 * @date 2022-06-01
 */
@RestController
@RequestMapping("/produce/whinapplyitem")
public class WhinapplyitemController extends BaseController
{
    @Autowired
    private IWhinapplyitemService whinapplyitemService;

    /**
     * 查询入库申请单明细列表
     */
    @PreAuthorize("@ss.hasPermi('produce:whinapplyitem:list')")
    @GetMapping("/list")
    public TableDataInfo list(Whinapplyitem whinapplyitem)
    {
        startPage();
        List<Whinapplyitem> list = whinapplyitemService.selectWhinapplyitemList(whinapplyitem);
        return getDataTable(list);
    }

    /**
     * 导出入库申请单明细列表
     */
    @PreAuthorize("@ss.hasPermi('produce:whinapplyitem:export')")
    @Log(title = "入库申请单明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Whinapplyitem whinapplyitem)
    {
        List<Whinapplyitem> list = whinapplyitemService.selectWhinapplyitemList(whinapplyitem);
        ExcelUtil<Whinapplyitem> util = new ExcelUtil<Whinapplyitem>(Whinapplyitem.class);
        return util.exportExcel(list, "whinapplyitem");
    }

    /**
     * 获取入库申请单明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('produce:whinapplyitem:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(whinapplyitemService.selectWhinapplyitemById(guid));
    }

    /**
     * 新增入库申请单明细
     */
    @PreAuthorize("@ss.hasPermi('produce:whinapplyitem:add')")
    @Log(title = "入库申请单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Whinapplyitem whinapplyitem)
    {
        return toAjax(whinapplyitemService.insertWhinapplyitem(whinapplyitem));
    }

    /**
     * 修改入库申请单明细
     */
    @PreAuthorize("@ss.hasPermi('produce:whinapplyitem:edit')")
    @Log(title = "入库申请单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Whinapplyitem whinapplyitem)
    {
        return toAjax(whinapplyitemService.updateWhinapplyitem(whinapplyitem));
    }

    /**
     * 删除入库申请单明细
     */
    @PreAuthorize("@ss.hasPermi('produce:whinapplyitem:remove')")
    @Log(title = "入库申请单明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(whinapplyitemService.deleteWhinapplyitemByIds(guids));
    }
}
